home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
archiver
/
zipv107.zip
/
ZIPV.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-03-16
|
25KB
|
1,047 lines
page 74,132
title ZIPV - Display directory of ZIP files
; name: ZIPV, version 1, 7 March 1989
; copyright: 1989, for personal use only; may not be sold.
; author: Vernon D. Buerg
;
; syntax:
; ZIPV [filespec[.ZIP] [/p] [/b] [/c]
; where:
; /p pauses the display after a screen full
; /b suppresses display of d:\path information for bbs use
; /c displays ZIPfile and file comments and extra fields
;
; output:
; - errorlevel returned:
; 0 - normal completion
; 1 - wrong DOS version
; 2 - no files found
; 3 - some invalid ZIP file(s) encountered
;
; notes:
; - supports DOS 3 file sharing
; - requires about 56k of memory, figure 64k for a .COM program
; - assembled using SLR Systems OPTASM; you figure the JMPs for MASM
; - handles self-extracting ZIP files (.EXE type)
.xlist
print macro name ; display a field
mov dx,offset name
call prints
endm
printl macro text ; display a literal
local txt,nxt
mov dx,offset txt
call prints
jmp nxt
txt db cr,lf,text
db stopper
nxt equ $
endm
save macro reglist ; save registers
irp reg, <reglist>
push reg
endm
endm
restore macro reglist ; restore registers
irp reg, <reglist>
pop reg
endm
endm
.list
central_dir struc ; from APPNOTES.TXT
cd_sig db 02h,01h,4bh,50h ; signature
cdver_made db 0,0 ; version made by
cdver_ext db 0,0 ; version to extract
cd_flag db 0,0 ; general purpose bit flag
cd_method dw 0 ; compression method
cd_mod_time dw 0 ; last mod time
cd_mod_date dw 0 ; last mod date
cd_crc dw 0,0 ; crc-32
cd_comp_size dw 0,0 ; compressed size
cd_true_size dw 0,0 ; uncompressed size
cd_flnm_len dw 0 ; filename length
cd_extra_len dw 0 ; extra field length
cd_comment_len dw 0 ; file comment length
cd_disk_start dw 0 ; disk number start
cd_intfile_attr dw 0 ; internal file attributes
cd_extfile_attr dw 0,0 ; external file attributes
cd_local_offset dw 0,0 ; file offset of local header
; variable length fields follow (boo-hiss)
central_dir ends
cd_filename equ size central_dir; filename (variable size)
cd_extra equ size central_dir; extra field (variable size)
cd_comment equ size central_dir; file comment (variable size)
central_end struc ; length 22+n
ce_sig db 06h,05h,4bh,50h ; signature
ce_disk_number dw 0 ; number of this disk
ce_disk_start dw 0 ; disk number with central dir start
ce_disk_entries dw 0 ; entries in central dir on this disk
ce_entries dw 0 ; total entries in central dir
ce_size dw 0,0 ; size of central dir
ce_offset dw 0,0 ; offset to central dir on this disk
ce_comment_len dw 0 ; length of zipfile comment
; variable length fields follow (nerts)
central_end ends
ce_comment equ size central_end; zipfile comment (variable size)
dtantry struc ; DOS Data Transfer Area
dtarsvd db 21 dup (0) ; reserved
dtaattr db 0 ; attribute
dtatime dw 0 ; update time
dtadate dw 0 ; update date
dtasize dw 0,0 ; size bytes (lo,hi)
dtaname db 12 dup (' ') ; name and ext
db 0,13,10,255 ; stopper and print
dtantry ends
subttl ZIPV - Mainline routines
page
cseg segment public para 'CODE'
assume cs:cseg, ds:cseg, ss:cseg, es:cseg
org 100h
zipv proc far
jmp start ; skip around data
subttl --- constants, equates and data areas
page
bel equ 7 ; honker
bs equ 8 ; backspace
tab equ 9 ; tabski
lf equ 10 ; Line Feed
cr equ 13 ; la Carriage Return
eof equ 26 ; end of file character
stopper equ 255 ; ends print strings
db bs,bs,bs,' ' ; overlay entry jmp for type
usage db cr,lf, 'ZIPV Version 1.07 Copyright (c) 1989 Vernon D. Buerg'
db cr,lf, 'For personal use only. May not be sold.'
db cr,lf,lf,' Usage: zipv [d:][\path\]filespec[.ZIP] [/p] [/b] [/c]'
db cr,lf
db cr,lf, ' Where: /P pauses after each screenful'
db cr,lf, ' /B suppresses display of d:\path'
db cr,lf, ' /C displays comments'
db cr,lf,stopper,eof
errlvl db 0 ; dos error level returned
opencod db 0 ; open code for share
flags db 255 ; find-first return code
options db 0 ; command options
b_parm equ 1 ; /b -bbs display option
p_parm equ 2 ; /p -pause at screen full
c_parm equ 4 ; /c - display comments
stkptr dw 0 ; stack pointer upon entry
ce_ptr dw 0 ; offset to central_end dir record
ce_count dw 0 ; count of entries in central dir
fileptr dw filenm ; spot after d:\path
filehdl dw 0 ; file handle
ziptitl db cr,lf,'Archive: ',stopper
zipname db 13 dup (0),0,stopper ; ZIP file name for heading
; display lines for verbose
vhdr db cr,lf
db cr,lf,'Name Length Method SF Size now Mod Date Time CRC-32 '
dashes db cr,lf,'============ ======== ======== ==== ======== ========= ====== ========'
db stopper
vline db cr,lf
vname db 14 dup (' ')
vsize db ' 0 ' ; acutal file size
vstyle db ' ' ; compression method
vfactor db ' xx% ' ; compression factor
vlength db 10 dup (' ') ; compressed length
vdate db 'dd ' ; creation date
vmonth db 'mmm '
vyear db 'yy '
vtime db 'hh:mm ' ; creation time
vcrc db 'xxxxxxxx' ; crc in hex
db stopper
len_vline equ $-vline ; length of print line
totsf dw 0,0 ; average stowage factor
totlen dw 0,0 ; total of file lengths
totsize dw 0,0 ; total of file sizes
totmbrs dw 0 ; total number of files
; final totals line
vthdr db cr,lf,'*total'
vtmbrs db ' '
vtsize db 8 dup (' '),' '
db 10 dup (' ')
vtsf db ' % '
vtlen db 8 dup (' ')
db cr,lf
db stopper
sign db ' '
vtotal db '*total'
ctitle db cr,lf,'Comment: ',stopper
cextra db cr,lf,'Extra: ',stopper
styles db 'Stored ' ; compression method names
db 'Shrunk '
db 'Reduced1'
db 'Reduced2'
db 'Reduced3'
db 'Reduced4'
hundred dw 100 ; for computing percentages
months db 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec '
subttl --- Mainline
page
start:
mov sp,offset cs:stk_end ; local stack
mov stkptr,sp ; save for dos return
mov ah,30h ; get dos version
int 21h ;
cmp al,2 ; version 2 or later?
jb badver ; no, gotta quit
cmp al,3 ; enough for share?
jb dos_okay ; no, open as-is
mov opencod,40h ; yes, add read-only
dos_okay:
mov bx,paras ; size of program
mov ah,4ah ; shrink allocated memory
int 21h ; setblock function
mov di,offset filenm ; clear operands
mov cx,offset stk-filenm ; and work areas
mov al,0 ;
rep stosb ;
subttl --- gather command line parameters
page
getparm:
mov si,82h ; Command tail
sub cx,cx ;
or cl,byte ptr -2[si] ; test parm length
jz getparms ; none, return as-is
sw1: lodsb ; scan for switch
cmp al,'/' ;
loopne sw1 ;
or cx,cx ; found one?
jz getparms ; no, done
mov byte ptr -1[si],cr ; yes, stop command line there
jmp sw2a ; and check next character
sw2: lodsb ; Next character
cmp al,'/' ; Another switch?
loopne sw2 ;
jcxz getparms ;
sw2a: lodsb ; yes, get letter following
and al,0dfh ; make upper case
dec cx ;
jle sw3 ; missing switch
sw3: cmp al,'P' ; Pause?
jne sw4 ;
or options,p_parm ;
sw4: cmp al,'B' ; BBS use
jne sw5 ;
or options,b_parm ;
sw5: cmp al,'C' ; display Comments?
jne sw2 ;
or options,c_parm ;
jmp sw2 ; Try for another option
subttl --- Gather command operands
page
; copy first command line operand as ZIP selection filespec
getparms:
mov si,80h ; offset to command line
sub cx,cx ; its length
or cl,byte ptr [si] ; any operand?
jnz parm0 ; no,
print usage ; display usage
jmp zipv_exit ; and quit
parm0: inc si ; point to operands
parm2: lodsb ; strip leading blanks
cmp al,' ' ;
loope parm2 ;
mov di,offset filenm ; first operand target
stosb ;
parm3: lodsb ; copy filename